package geor.model;

import geor.app.R;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import lib.model.Helper;

public class CompraHelper extends Helper {
	
	public static final String WHERE_MES_ANO = " WHERE strftime('%m/%Y', cpp.vencimento) is ? ";
	public static final String TABLE_NAME = "contas_pagar";
	public static final String SUBTABLE_NAME = "contas_pagar_parcela";
	
	public CompraHelper(Context context) {
		super(context);
	}

	@Override
	public long create(ContentValues values) {
		return create(TABLE_NAME, "descricao", values);
	}

	@Override
	public Cursor read(String id) {
		return null;
	}

	@Override
	public void update(String id, ContentValues values) {
		this.update("contas_pagar", values, id);
	}

	@Override
	public boolean delete(String id) {
		return false;
	}

	@Override
	public Cursor readAll(String whereClause, String[] whereArgs) {
		String query = resources.getString(R.string.sql_compra_helper_read_all)
			+ whereClause;
		return getReadableDatabase().rawQuery(query, whereArgs);
	}

	public Cursor countItensRestantes(String whereClause, String[] whereArgs) {
		String query = resources.getString(R.string.sql_compra_helper_count_restantes)
			+ whereClause;
		return getReadableDatabase().rawQuery(query, whereArgs);
	}
	
	public Cursor comprasMesAtual(String whereClause, String[] whereArgs) {
		String query = resources.getString(R.string.sql_compra_helper_compras_mes_atual)
			+ whereClause;
		return getReadableDatabase().rawQuery(query, whereArgs);
	}
	
	public Cursor resumoComprasMes() {
		String query = resources.getString(R.string.sql_compra_helper_resumo_compras);
		return getReadableDatabase().rawQuery(query, null);
	}

	@Override
	public Cursor contas_Mes(String data) {
		return null;
	}

	@Override
	public Cursor contas_Pagar(String data) {
		return null;
	}
}
